package com.core.model.user;

import com.core.dto.UserDTO;
import com.core.model.AbstractEntity;
import com.core.model.UploadImage;
import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-1-5
 * Time: 下午2:23
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "user_info")
public class UserInfo extends AbstractEntity implements Serializable {

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id")
    private User user;
    @Column
    private String nickname;

    public UserInfo() {
    }

    public UserInfo(User user) {
        this.user = user;
    }

    public UserInfo(User user, String nickname) {
        this.user = user;
        this.nickname = nickname;
    }

    public void initUserInfo(UserDTO userDTO) {
        this.nickname = userDTO.getNickname();
    }

    public String nickname() {
        return nickname;
    }

}
